﻿Module Module14
    ' 參考課本 2-33 頁
    Enum Gender As Integer
        Girl = 0
        Boy = 1
    End Enum

    ' 參考課本 2-35 頁
    Structure Student
        Dim Name As String
        Dim Gender As Gender
        Dim Eng As Integer
        Dim Math As Integer
    End Structure

    Sub Main()
        Dim st(2) As Student
        Console.WriteLine("st.Length=" & st.Length)
        For idx As Integer = 0 To st.Length - 1
            Console.WriteLine("輸入第 {0} 位學生資料", idx)

            Console.Write("Name: ")
            st(idx).Name = Console.ReadLine()

            Console.Write("Gender (0:Girl 1:Boy) :")
            st(idx).Gender = Val(Console.ReadLine())

            Console.Write("Eng: ")
            st(idx).Eng = Val(Console.ReadLine())

            Console.Write("Math: ")
            st(idx).Math = Val(Console.ReadLine())
        Next

        Console.WriteLine()
        Console.WriteLine("Name" & vbTab & "Gender" & vbTab & "Eng" & vbTab & "Math")
        For Each x As Student In st
            Console.WriteLine(x.Name & vbTab & IIf(x.Gender = Gender.Boy, "Boy", "Girl") & vbTab & x.Eng & vbTab & x.Math)
        Next
        Console.ReadKey()
    End Sub
End Module
